GraphQL and SpaceQL

Smart DIHClosed Smart DIH allows enterprises to develop and deploy digital services in an agile manner, without disturbing core business applications. This is achieved by creating an event-driven, highly performing, efficient and available replica of the data from multiple systems and applications, includes embedded GraphQL API Gateway functionality.

The GraphQL API Gateway service allows to query XAPClosed GigaSpaces eXtreme Application Platform. Provides a powerful solution for data processing, launching, and running digital services spaces using GraphQL syntax.

The service detects all Spaces and corresponding types that exist in each SpaceClosed Where GigaSpaces data is stored. It is the logical cache that holds data objects in memory and might also hold them in layered in tiering. Data is hosted from multiple SoRs, consolidated as a unified data model.. It then auto-generates GraphQL functions that can be used to easily query the Space and retrieve faster results in comparison to using the equivalent SQL queries.

You can query the GraphQL service through SpaceQL, or using the DIHCTL application.

Enable GraphQL

To enable GraphQL, add the following global option when installing Smart DIHClosed Digital Integration Hub. An application architecture that decouples digital applications from the systems of record, and aggregates operational data into a low-latency data fabric.:

--set global.graphql.enabled=true

SpaceQL

SpaceQL is a GraphQL user interface, integrated in the DIH SpaceDeckClosed GigaSpaces intuitive, streamlined user interface to set up, manage and control their environment. Using SpaceDeck, users can define the tools to bring legacy System of Record (SoR) databases into the in-memory data grid that is the core of the GigaSpaces system.. It allows to perform interactive GraphQL queries.

For an overview of the SpaceQL menu in SpaceDeck, refer to the SpaceDeck - SpaceQL page.

Configure Relations Between GraphQL Schemas

You can configure relations between GraphQL schemas:

  • Through SpaceQL, as above.

  • Using the DIHCTL application, for example:

    This yaml file contains relations between two tables - customers and orders, and orders and products:

    graphqlTypes:
    - name: "CUSTOMERS"
      space: "demo"
      relations:
      - name: "orders"
        referencedType: "ORDERS"
        referencedTypeSpace: "demo"
        usingId: false
        foreignKeyColumn: "CUSTOMER_ID"
        referencedTypeColumn: "CUSTOMER_ID"
    - name: "ORDERS"
      space: "demo"
      relations:
      - name: "product"
        referencedType: "PRODUCTS"
        referencedTypeSpace: "demo"
        usingId: true
        foreignKeyColumn: "PRODUCT_ID"

    This file can be applied and the two relations can be created using the following command:

    ./dihctl -e YOUR_ENV apply -f PATH_TO_FILE.yaml

Export Existing Relations

You can export existing relations for all Spaces in a cluster:

  • Through SpaceQL, as above.

  • Using the DIHCTL application, by performing the following command:

    ./dihctl -e YOUR_ENV export relations -o OUTPUT_FILE_NAME.yaml

Query the GraphQL Service Using DIHCTL

Example 1: Querying a Customer

This example shows querying a customer after creating relevant relations that will hold all relevant data regarding the customer's orders and corresponding order products.

query customers($customerId: BigDecimal!) {
    demo_customersById(CUSTOMER_ID: $customerId) {
        COMMENTS CREDIT_LIMIT CUSTOMER_CITY CUSTOMER_COUNTRY CUSTOMER_FIRST_NAME
        CUSTOMER_ID CUSTOMER_LAST_NAME CUSTOMER_STREET
        CUSTOMER_ZIPCODE DATE_OF_BIRTH EMAIL GENDER INCOME_LEVEL
        LAST_UPDATE PHONE_NUMBER ZZ_META_DIClosed The Data Integration (DI) layer is a vital part of the Digital Integration Hub (DIH) platform. It is responsible for a wide range of data integration tasks such as ingesting data in batches or streaming data changes. This is performed in real-time from various sources and systems of record (SOR. The data then resides in the In-Memory Data Grid (IMDG), or Space, of the GigaSpaces Smart DIH platform._TIMESTAMP
        orders {
            CARD_TYPE CUSTOMER_ID LAST_UPDATE ORDER_DATE ORDER_ID
            ORDER_NOTES ORDER_STATUS ORDER_TOTAL PRODUCT_ID ZZ_META_DI_TIMESTAMP
            product {
                CATALOG_URL LAST_UPDATE LIST_PRICE PRODUCT_DESCRIPTION
                PRODUCT_ID PRODUCT_NAME PRODUCT_SIZE ZZ_META_DI_TIMESTAMP
            }
        }
    }
}